Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Azure Container Apps session execute new api-version #8249

Merged

Conversation

yitaopan
Copy link
Member

@yitaopan yitaopan commented Nov 8, 2024


This checklist is used to make sure that common guidelines for a pull request are followed.

Related command

az containerapp session code-interpreter

General Guidelines

  • Have you run azdev style <YOUR_EXT> locally? (pip install azdev required)
  • Have you run python scripts/ci/test_index.py -q locally? (pip install wheel==0.30.0 required)
  • My extension version conforms to the Extension version schema

For new extensions:

About Extension Publish

There is a pipeline to automatically build, upload and publish extension wheels.
Once your pull request is merged into main branch, a new pull request will be created to update src/index.json automatically.
You only need to update the version information in file setup.py and historical information in file HISTORY.rst in your PR but do not modify src/index.json.

Copy link

azure-client-tools-bot-prd bot commented Nov 8, 2024

⚠️Azure CLI Extensions Breaking Change Test
⚠️containerapp
rule cmd_name rule_message suggest_message
⚠️ 1006 - ParaAdd containerapp session code-interpreter delete-file cmd containerapp session code-interpreter delete-file added parameter path
⚠️ 1006 - ParaAdd containerapp session code-interpreter show-file-content cmd containerapp session code-interpreter show-file-content added parameter path
⚠️ 1006 - ParaAdd containerapp session code-interpreter show-file-metadata cmd containerapp session code-interpreter show-file-metadata added parameter path
⚠️ 1006 - ParaAdd containerapp session code-interpreter upload-file cmd containerapp session code-interpreter upload-file added parameter path

Copy link

Hi @yitaopan,
Please write the description of changes which can be perceived by customers into HISTORY.rst.
If you want to release a new extension version, please update the version in setup.py as well.

@yonzhan
Copy link
Collaborator

yonzhan commented Nov 8, 2024

Thank you for your contribution! We will review the pull request and get back to you soon.

Copy link

github-actions bot commented Nov 8, 2024

CodeGen Tools Feedback Collection

Thank you for using our CodeGen tool. We value your feedback, and we would like to know how we can improve our product. Please take a few minutes to fill our codegen survey

Copy link

github-actions bot commented Nov 8, 2024

Hi @yitaopan

Release Suggestions

Module: containerapp

  • Update VERSION to 1.0.0b5 in src/containerapp/setup.py

Notes

@@ -1018,7 +1017,7 @@ def list(cls, cmd, resource_group_name, environment_name):


class SessionPoolPreviewClient():
api_version = SESSION_API_VERSION
api_version = PREVIEW_API_VERSION
Copy link
Contributor

@Greedygre Greedygre Nov 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will ask azure cli folks help to merge this PR: #8223

It will have some conflict with your PR.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR has been merge. Please resolve the conflict.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Merged and conflicts resolved.

request_url = url_fmt.format(
session_pool_endpoint,
"path=" + path + "&" if path is not None else "",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"path=" + path + "&" if path is not None else "",
f"path={path}&" if path is not None else "",

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

def show_file_content(cls, cmd, identifier, filename, session_pool_endpoint):
url_fmt = "{}/files/content/{}?identifier={}&api-version={}"
def show_file_content(cls, cmd, identifier, filename, path, session_pool_endpoint):
url_fmt = "{}/files/{}/content?{}identifier={}&api-version={}"

This comment was marked as resolved.

This comment was marked as resolved.

request_url = url_fmt.format(
session_pool_endpoint,
filename,
"path=" + path + "&" if path is not None else "",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"path=" + path + "&" if path is not None else "",
f"path={path}&" if path is not None else "",

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

request_url = url_fmt.format(
session_pool_endpoint,
filename,
"path=" + path + "&" if path is not None else "",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"path=" + path + "&" if path is not None else "",
f"path={path}&" if path is not None else "",

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

@@ -435,7 +435,7 @@ def load_arguments(self, _):
with self.argument_context('containerapp session code-interpreter', arg_group='file') as c:
c.argument('filename', help="The file to delete or show from the session")
c.argument('filepath', help="The local path to the file to upload to the session")
c.argument('path', help="The path to list files from the session")
c.argument('path', help="The path of files in the session")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Recommend to add an example for --path in the _help.py

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

Comment on lines 89 to 92
if self.get_argument_timeout_in_seconds() is not None:
self.session_code_interpreter_def["properties"]["timeoutInSeconds"] = self.get_argument_timeout_in_seconds()
self.session_code_interpreter_def["timeoutInSeconds"] = self.get_argument_timeout_in_seconds()
else:
self.session_code_interpreter_def["properties"]["timeoutInSeconds"] = 60
self.session_code_interpreter_def["properties"]["code"] = self.get_argument_code()
self.session_code_interpreter_def["timeoutInSeconds"] = 60
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The self.get_argument_timeout_in_seconds() will never be None because there is a default value:

   --timeout-in-seconds           : Duration in seconds code in session can run prior to timing out
                                     0 - 60 secs, e.g. 30.  Default: 60.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make sense, fixed.

request_url = url_fmt.format(
session_pool_endpoint,
filename,
"path=" + path + "&" if path is not None else "",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as L1186

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, fixed

@@ -7,6 +7,8 @@ upcoming
* 'az containerapp create': Fix Role assignment error when the default Azure Container Registry could not be found
* Upgrade api-version to 2024-10-02-preview
* 'az containerapp create/update': `--yaml` support property pollingInterval and cooldownPeriod
* 'az containerapp session code-interpreter': `--path` support upload-file/list-files/show-file-content/show-file-metadata/delete-file for code interpreter sessions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* 'az containerapp session code-interpreter': `--path` support upload-file/list-files/show-file-content/show-file-metadata/delete-file for code interpreter sessions
* 'az containerapp session code-interpreter upload-file/list-files/show-file-content/show-file-metadata/delete-file': Support `--path` to specify the path of code interpreter session

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

"code": None,
"timeoutInSeconds": None
}
"codeInputType": None,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

with one property identifier removed?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The backend Api is switched to use 2024-10-02-preview in this PR, in which the identifier property is removed in the payload, but still exists in the query parameter.

@@ -119,10 +109,5 @@ def test_containerapp_session_code_interpreter_nodelts_e2e(self, resource_group)
resource_group,
))

self.cmd("containerapp sessionpool delete -n {} -g {} --yes".format(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why remove the deletion code?

Copy link
Member Author

@yitaopan yitaopan Nov 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is to remove the deletion of that earlier created PythonLTS session pool https://github.com/Azure/azure-cli-extensions/pull/8249/files/dd6dc3deae0818beb7408a423208e136fd4d31a2#r1836222120

@@ -96,7 +86,7 @@ def test_containerapp_session_code_interpreter_nodelts_e2e(self, resource_group)
identifier_name,
"cert.txt"),
checks=[
JMESPathCheck('properties.filename', 'cert.txt'),
JMESPathCheck('name', 'cert.txt'),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

such change is breaking for cli users. Can we make sure there is no change for cli command output?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are breaking changes in the output of these commands in api-version 2024-10-02-preview, which is reviewed by swagger and sdk team.
The HISTORY.rst file is updated for this.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Even there is breaking change in swagger, we should still avoid breaking change in cli commands. Discussed with hong, given there is no cli usage, we could allow cli breaking change this time. But in the future, with increasing cli users, such breaking change is not allowed.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, understood, will keep in mind for this in the future.

@@ -25,16 +25,6 @@ def test_containerapp_session_code_interpreter_nodelts_e2e(self, resource_group)
sessionpool_list = self.cmd("containerapp sessionpool list -g {}".format(resource_group)).get_output_in_json()
self.assertTrue(len(sessionpool_list) == 0)

# Create PythonLTS SessionPool with default container type which is PythonLTS
sessionpool_name_pythonlts = self.create_random_name(prefix='sppythonlts', length=24)
self.cmd('containerapp sessionpool create -g {} -n {} --cooldown-period {}'.format(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why remove this command?

Copy link
Member Author

@yitaopan yitaopan Nov 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because I think this file should be focusing on NodeLTS session pool, and all the validation is targeting NodeLTS pool rather than the Python session pool created here.
And for the tests and validations against PythonLTS session pools are duplicated in another test file test_containerapp_session_code_interpreter.py.

Comment on lines +51 to +52
JMESPathCheck('status', 'Succeeded'),
JMESPathCheck('result.stdout', 'Hello world\n')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

avoid such breaking change. recommend to transform output for consistence

Comment on lines 1290 to 1298
@classmethod
def extract_path_from_filename(cls, path, filename):
if '/' not in filename:
return path, filename
path_in_filename, filename = filename.rsplit('/', 1)
if path is None:
return path_in_filename, filename
else:
return path.rstrip("/") + "/" + path_in_filename.lstrip('/'), filename
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should be a static method.

Suggested change
@classmethod
def extract_path_from_filename(cls, path, filename):
if '/' not in filename:
return path, filename
path_in_filename, filename = filename.rsplit('/', 1)
if path is None:
return path_in_filename, filename
else:
return path.rstrip("/") + "/" + path_in_filename.lstrip('/'), filename
@staticmethod
def extract_path_from_filename(path, filename):
if '/' not in filename:
return path, filename
path_in_filename, filename = filename.rsplit('/', 1)
if path is None:
return path_in_filename, filename
full_path = f"{path.rstrip('/')}/{path_in_filename.lstrip('/')}"
return full_path, filename

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, fixed

@Greedygre
Copy link
Contributor

Hi @yonzhan @zhoxing-ms
This PR has been reviewed and approved inner our team, can you help to review it when you have chance? Thanks!

@yanzhudd
Copy link
Contributor

/azp run

Copy link

Azure Pipelines successfully started running 2 pipeline(s).

@@ -1281,6 +1287,16 @@ def list_files(cls, cmd, identifier, path, session_pool_endpoint):

r = send_raw_request(cmd.cli_ctx, "GET", request_url, resource=SESSION_RESOURCE)
return r.json()

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CI style failed
src/containerapp/azext_containerapp/_clients.py:1290:0: C0303: Trailing whitespace (trailing-whitespace)

remove the whitespece

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, fixed

@yanzhudd
Copy link
Contributor

/azp run

Copy link

Azure Pipelines successfully started running 2 pipeline(s).

@yanzhudd yanzhudd merged commit cf2c792 into Azure:main Nov 12, 2024
21 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Auto-Assign Auto assign by bot ContainerApp
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants